# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  
  # Shortcut to add title on the fly
  def title(name)
    content_for(:title) { name + " | #{current_account.name} - Simo 1.0" }
  end
  
  def content_for_header(content)
    content_for(:header) { content }
  end
  
  # User logged in
  def user_logged_in?
    session[:user_id]
  end
  
  # Check if user is admin
  def user_is_admin?
    user_logged_in? && (user = User.find(session[:user_id])) && user.admin
  end
  
  def current_page(page)
    content_for(:current_page) { page }
  end
end
